-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Codegen template error in RCTThirdPartyFabricComponentsProvider #34738
Closed
gispada
wants to merge
1
commit into
facebook:main
from
gispada:fix/codegen-generate-third-party-components-provider
Closed
Fix: Codegen template error in RCTThirdPartyFabricComponentsProvider #34738
gispada
wants to merge
1
commit into
facebook:main
from
gispada:fix/codegen-generate-third-party-components-provider
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Sep 20, 2022
facebook-github-bot
added
the
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
label
Sep 20, 2022
Base commit: bcb5808 |
Base commit: c27501b |
cipolleschi
approved these changes
Sep 21, 2022
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by Gianluca Spada in 2f6b212. When will my fix make it into a release? | Upcoming Releases |
dmytrorykun
pushed a commit
that referenced
this pull request
Oct 19, 2022
…34738) Summary: When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation: - The same library exports multiple modules with one component each (i.e. one component per file); - The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*. A "loose" comma appears in the generated template, breaking the code. ```c++ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { , // <-- the offending comma {"NativeComponent2", NativeComponent2Cls}, // rnmylibrary }; } ``` At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider Pull Request resolved: #34738 Test Plan: <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. --> This is the schema that leads to the bug. Notice that the first component was excluded for iOS. ```json { "modules": { "ComponentFile1": { "type": "Component", "components": { "NativeComponent1": { "excludedPlatforms": ["iOS"] "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } }, "ComponentFile2": { "type": "Component", "components": { "NativeComponent2": { "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } } } ``` `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2). I also added an additional test case to cover this problem. All the other tests passed. Reviewed By: sammy-SC Differential Revision: D39686573 Pulled By: cipolleschi fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
brentvatne
pushed a commit
to expo/react-native
that referenced
this pull request
Oct 28, 2022
…acebook#34738) Summary: When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation: - The same library exports multiple modules with one component each (i.e. one component per file); - The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*. A "loose" comma appears in the generated template, breaking the code. ```c++ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { , // <-- the offending comma {"NativeComponent2", NativeComponent2Cls}, // rnmylibrary }; } ``` At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider Pull Request resolved: facebook#34738 Test Plan: <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. --> This is the schema that leads to the bug. Notice that the first component was excluded for iOS. ```json { "modules": { "ComponentFile1": { "type": "Component", "components": { "NativeComponent1": { "excludedPlatforms": ["iOS"] "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } }, "ComponentFile2": { "type": "Component", "components": { "NativeComponent2": { "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } } } ``` `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2). I also added an additional test case to cover this problem. All the other tests passed. Reviewed By: sammy-SC Differential Revision: D39686573 Pulled By: cipolleschi fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
OlimpiaZurek
pushed a commit
to OlimpiaZurek/react-native
that referenced
this pull request
May 22, 2023
…acebook#34738) Summary: When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation: - The same library exports multiple modules with one component each (i.e. one component per file); - The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*. A "loose" comma appears in the generated template, breaking the code. ```c++ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { , // <-- the offending comma {"NativeComponent2", NativeComponent2Cls}, // rnmylibrary }; } ``` At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider Pull Request resolved: facebook#34738 Test Plan: <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. --> This is the schema that leads to the bug. Notice that the first component was excluded for iOS. ```json { "modules": { "ComponentFile1": { "type": "Component", "components": { "NativeComponent1": { "excludedPlatforms": ["iOS"] "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } }, "ComponentFile2": { "type": "Component", "components": { "NativeComponent2": { "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } } } ``` `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2). I also added an additional test case to cover this problem. All the other tests passed. Reviewed By: sammy-SC Differential Revision: D39686573 Pulled By: cipolleschi fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
Platform: iOS
iOS applications.
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When
GenerateRCTThirdPartyFabricComponentsProviderCpp.js
generatesRCTThirdPartyFabricComponentsProvider.mm
an edge case happens in the following situation:excludedPlatforms
property in codegenNativeComponent.A "loose" comma appears in the generated template, breaking the code.
At some point,
GenerateRCTThirdPartyFabricComponentsProviderCpp.js
does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library.Changelog
[iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider
Test Plan
This is the schema that leads to the bug. Notice that the first component was excluded for iOS.
GenerateRCTThirdPartyFabricComponentsProviderCpp.js
should generate a template without the comma in the wrong position (before NativeComponent2).I also added an additional test case to cover this problem. All the other tests passed.